home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Media Design Review 1999
/
Interactive Media Design Review 1999.iso
/
pc
/
Demos
/
Herois
/
Codigo.Cst
/
00073_Script_PaginasGenerico
< prev
next >
Wrap
Text File
|
1999-03-19
|
14KB
|
484 lines
property sprIndicadorScroll -- Sprite com botao de scroll
property estado -- 0 para generico, 1 para alfabetico
property spr
property memMe -- Membro que contem lista
property intPalavraClicada -- Palavra digitada
-- Palavras selecionadas (clicadas)
property intIndicePaginas, intIndiceMidias
-- Ataualizacao da lista
property bBuscando
property intScroll, intLinhas
property strLista, intNovasLinhas
property timeUltimaAtualizacao
-- Descricao da Behavior
on getBehaviorDescription
return "Gerencia lista de paginas"
end
on getPropertyDescriptionList
set p_list = [ ¼
#sprIndicadorScroll: [ #comment: "Sprite do indicador de scroll", ¼
#format: #integer, ¼
#default: "" ] ¼
]
return p_list
end
-- Inicializacao do sprite
on beginSprite me
set spr = the spriteNum of me
put the member of sprite spr into memMe
put 0 into intScroll
put 0 into intLinhas
set the text of member memMe to ""
set strLista to ""
set intNovasLinhas to 0
set bBuscando to false
set estado = 0
set intIndicePaginas = []
set intIndiceMidias = []
set intPalavraClicada = 0
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
set the fontSize of member memMe to¼
the fontSize of member "TipoLetra"
set the font of member memMe to¼
the font of member "TipoLetra"
end
-- Mensagens de scroll
on scrollingUp me
if intScroll > 0 then
scrollByLine member memMe, -1
put intScroll - 1 into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
end if
updateStage
set tmp = the timer + 20
repeat while the mouseDown
if intScroll > 0 and the timer - tmp > 6 then
scrollByLine member memMe, -1
put intScroll - 1 into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
updateStage
set tmp = the timer
end if
-- Faz idle sprite
global gMustUpdate
set gMustUpdate = false
sendAllSprites(#idleSprite)
if gMustUpdate then updateStage
end repeat
end
on scrollingDown me
if intLinhas > 5 and intScroll < intLinhas - 1 then
scrollByLine member memMe, +1
put 1 + intScroll into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
updateStage
end if
set tmp = the timer + 20
repeat while the mouseDown
if intLinhas > 5 and intScroll < intLinhas - 1 and the timer - tmp > 6 then
scrollByLine member memMe, +1
put 1 + intScroll into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll * 10000 / (intLinhas-1))
updateStage
set tmp = the timer
end if
-- Faz idle sprite
global gMustUpdate
set gMustUpdate = false
sendAllSprites(#idleSprite)
if gMustUpdate then updateStage
end repeat
end
on scrollPaginaCima
if intLinhas <= 5 then return
put intScroll-5 into tmp
if tmp < 0 then put 0 into tmp
scrollByLine member memMe, tmp - intScroll
put tmp into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll*10000/(intLinhas-1))
updateStage
end
on scrollPaginaBaixo
if intLinhas <= 5 then return
put intScroll+5 into tmp
if tmp > intLinhas - 1 then put intLinhas - 1 into tmp
scrollByLine member memMe, tmp - intScroll
put tmp into intScroll
sendSprite(sprIndicadorScroll, #move, intScroll*10000/(intLinhas-1))
updateStage
end
on scrollArraste me, posicao
if intLinhas <= 5 then return
put posicao * (intLinhas - 1) / 10000 into tmp
scrollByLine member memMe, tmp - intScroll
put tmp into intScroll
end
on scrollArrasteFim me
if intLinhas <= 5 then
sendSprite(sprIndicadorScroll, #move, 0)
updateStage
end if
end
on scrollLinha me, linha
scrollByLine member memMe, linha - intScroll
set intScroll = linha
sendSprite(sprIndicadorScroll, #move, intScroll*10000/(intLinhas-1))
updateStage
end
-------------------------------------------------------------------
-------------------------------------------------------------------
-------------------------------------------------------------------
-- Zera lista
on zera me
put 0 into intScroll
put 0 into intLinhas
set strLista to ""
set intNovasLinhas to 0
set bBuscando to false
sendSprite(sprIndicadorScroll, #move, 0)
set intPalavraClicada = 0
set intIndicePaginas = []
set intIndiceMidias = []
set the text of field memMe to ""
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
-- set the fontSize of member memMe to¼
-- the fontSize of member "TipoLetra"
-- set the font of member memMe to¼
-- the font of member "TipoLetra"
end
-- Prenche lista com paginas onde ocorrem a palavra de indice <pal>
on preenche me, pal
global gRefs, gArqs
set intPalavraClicada = 0
-- put "PaginasGenerico: preenche # pal=" & pal
-- Limpa listas
put 0 into intScroll
put 0 into intLinhas
cursor 4
updateStage
put "" into strLista
set intNovasLinhas to 0
put [] into intIndicePaginas
put [] into intIndiceMidias
put false into bBuscando
-- Faz busca de referencias
mSetCriteria(gRefs,"palNum", "=", pal)
mSelect(gRefs)
put mSelectCount(gRefs) into counter
put counter into tmp
-- put "PaginasGenerico: preenche # matches=" & counter
-- Primeiro le referencias
put [] into lista
put [] into listaMidias
repeat while tmp > 0
set an = mGetField(gRefs,"arqNum")
if an = 8 then
if getPos(lista,7) = 0 then
add lista,7
add listaMidias, mGetField(gRefs,"mediaNum")
else
set counter = counter - 1
end if
else
add lista,an
add listaMidias, mGetField(gRefs,"mediaNum")
end if
mGoNext(gRefs)
put tmp-1 into tmp
end repeat
-- put "PaginasGenerico: preenche # indices=" & lista
-- Le titulos dos arquivos
mSetIndex(gArqs,"arqNdx")
put 1 into idx
repeat while counter > 0
-- Pega indice do arquivo/pagina
put getAt(lista,idx) into ai
put getAt(listaMidias,idx) into midias
put 1 into mi
put idx+1 into idx
-- Le titulo do arquivo
mSetCriteria(gArqs, "arqNum", "=", ai)
mSelect(gArqs)
put "- " & mGetField(gArqs,"arquivo") into titulo
-- Tira espaco no final do titulo
set i = length(titulo)
repeat while i > 0 and char i of titulo = SPACE
set i = i - 1
end repeat
set titulo = char 1 to i of titulo
-- Monta lista de indices
put the number of words in titulo into tmp
repeat while tmp > 0
add intIndicePaginas, ai
add intIndiceMidias, 1
put tmp-1 into tmp
end repeat
-- Atualiza lista
if (strLista <> "") then put RETURN after strLista
put titulo after strLista
if (midias <> 1) then
if (midias > 8) then
put midias - 8 into midias
add intIndicePaginas, ai
add intIndiceMidias, 8
put " [Cinema]" after strLista
end if
if (midias > 4) then
put midias - 4 into midias
add intIndicePaginas, ai
add intIndiceMidias, 4
put " [TV]" after strLista
end if
if (midias > 2) then
put midias - 2 into midias
add intIndicePaginas, ai
add intIndiceMidias, 2
put " [HQ]" after strLista
end if
end if
-- Proxima pagina
put counter - 1 into counter
end repeat
-- Reseta lista de palavras
global eMac
if eMac then
trocaTexto memMe, strLista, (the backColor of member "FundoPreto"), ¼
"PaginasGenerico", "PaginasGenericoBack"
else
set the text of field memMe to strLista
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
end if
updateStage
put 0 into intScroll
put the lineCount of member memMe into intLinhas
sendSprite(sprIndicadorScroll, #move, 0)
-- Atualiza "Stage"
cursor -1
updateStage
end
-- Seleciona pagina e vai para respectiva
on mouseUp me
put the mouseWord into mw
if mw < 1 then return
set tmp = count(intIndicePaginas)
if tmp = 0 then set tmp = (the number of items in field "ListaAlfabeticaRef") - 1
if mw > tmp then return
if count(intIndicePaginas) = 0 then
set tmp2 = 1
set tmp1 = Integer(item mw of field "ListaAlfabeticaRef")
else
put getAt(intIndicePaginas,mw) into tmp1
put getAt(intIndiceMidias,mw) into tmp2
end if
if the doubleClick then
puppetSound 2, "CliqueVaiVolta"
vaiPagina tmp1, true
else
if intPalavraClicada <> 0 then
if the estado of sprite 97 < 2 then
set cor = (the backColor of member "FundoPreto") -- black
else
set cor = (the backColor of member "FundoBranco") -- white
end if
if the platform contains "Mac" then
set the foreColor of member memMe to cor
else
pinta me, intPalavraClicada, cor
end if
end if
pinta me, mw, ¼
(the backColor of member "FundoAzul")
set intPalavraClicada = mw
-- Marca linha
end if
end
-- Seleciona novo membro
on setMembro me, strMembro
set the member of sprite spr to member strMembro
set memMe to the member of sprite spr
if the estado of sprite 97 < 2 then
set cor = (the backColor of member "FundoPreto") -- black
else
set cor = (the backColor of member "FundoBranco") -- white
end if
set the foreColor of member memMe to cor
-- set the fontSize of member memMe to¼
-- the fontSize of member "TipoLetra"
-- set the font of member memMe to¼
-- the font of member "TipoLetra"
end
-- Pinta palavras de indice de uma determinada cor
on pinta me, pal, cor
put count(intIndicePaginas) into max
set alfa = false
if max = 0 then
set max = the number of items in field "ListaAlfabeticaRef"
set arq = Integer(item pal of field "ListaAlfabeticaRef")
set alfa = true
else
put getAt(intIndicePaginas, pal) into arq
end if
-- put "PalavrasGenerico: pinta # pal=" & pal & ", idx=" & tmp &¼
-- ", cor=" & cor
set tmp = pal
-- Pinta palavras posteriores de mesmo indice (arq)
if alfa then set x = Integer(item pal of field "ListaAlfabeticaRef")
else set x = getAt(intIndicePaginas,pal)
repeat while x = arq
set the forecolor of word pal of member memMe to cor
put pal + 1 into pal
if pal > max then exit repeat
if alfa then set x = Integer(item pal of field "ListaAlfabeticaRef")
else set x = getAt(intIndicePaginas,pal)
end repeat
set pal = tmp - 1
-- Pinta palavras anteriores de mesmo indice
repeat while pal >= 1
if alfa then set x = Integer(item pal of field "ListaAlfabeticaRef")
else set x = getAt(intIndicePaginas,pal)
if x = arq then
set the forecolor of word pal of member memMe to cor
set pal = pal - 1
else
set pal = 0
end if
end repeat
end
-- Lista todas paginas em ordem alfabetica
on listaTodos me
cursor 4
updateStage
-- Reseta lista de palavras
set the foreColor of member memMe to ¼
(the backColor of member "FundoPreto")
put the lineCount of member memMe into intLinhas
set the scrollTop of member memMe to 0
put 0 into intScroll
sendSprite(sprIndicadorScroll, #move, 0)
set intIndicePaginas = []
cursor -1
end
-- Lista paginas selecionadas
on listaSelecionados me
global gArqs
set intPalavraClicada = 0
cursor 4
updateStage
-- Lista dos selecionados
global gPagSel, gPagArraste
set counter = count(gPagSel)
-- Prepara lista
put 1 into idx
put [] into intIndicePaginas
put [] into intIndiceMidias
set strLista = ""
repeat while counter > 0
-- Le registro
set ai = getAt(gPagSel,idx)
mSetCriteria(gArqs,"arqNum", "=", ai)
mSelect(gArqs)
set titulo = "- " & mGetField(gArqs,"arquivo")
-- Tira espaco no final do titulo
set i = length(titulo)
repeat while i > 0 and char i of titulo = SPACE
set i = i - 1
end repeat
set titulo = char 1 to i of titulo
-- Monta lista de indices
put the number of words in titulo into tmp
repeat while tmp > 0
add intIndicePaginas, ai
add intIndiceMidias, 1
put tmp-1 into tmp
end repeat
-- Atualiza lista
if (strLista <> "") then put RETURN after strLista
put titulo after strLista
-- Proxima pagina
put counter - 1 into counter
set idx = idx + 1
end repeat
-- Reseta lista de palavras
global eMac
if eMac then
trocaTexto memMe, strLista, (the backColor of member "FundoBranco"), ¼
"PaginasSelecionadas", "PaginasSelecionadasBack"
else
set the foreColor of member memMe to ¼
(the backColor of member "FundoBranco")
set the text of member memMe to strLista
set the foreColor of member memMe to ¼
(the backColor of member "FundoBranco")
set the scrollTop of member memMe to 0
end if
put 0 into intScroll
sendSprite(sprIndicadorScroll, #move, 0)
put the lineCount of member memMe into intLinhas
cursor -1
end
-- Adiciona
on addSelecionados me
global gPagSel, gPagArraste
end